﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.5
// Code is generated on: Monday, December 17, 2012 11:21:26 AM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using WHMS;
using WHMS.FactoryClasses;
using WHMS.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace WHMS.RelationClasses
{
	/// <summary>Implements the relations factory for the entity: SupplyOrder. </summary>
	public partial class SupplyOrderRelations
	{
		/// <summary>CTor</summary>
		public SupplyOrderRelations()
		{
		}

		/// <summary>Gets all relations of the SupplyOrderEntity as a list of IEntityRelation objects.</summary>
		/// <returns>a list of IEntityRelation objects</returns>
		public virtual List<IEntityRelation> GetAllRelations()
		{
			List<IEntityRelation> toReturn = new List<IEntityRelation>();
			toReturn.Add(this.SupplyOrderItemEntityUsingSupplyOrderId);
			toReturn.Add(this.CurrencyEntityUsingCurrencyId);
			toReturn.Add(this.ProjectEntityUsingProjectId);
			toReturn.Add(this.SupplierEntityUsingSupplierId);
			toReturn.Add(this.UserEntityUsingCreatedBy);
			return toReturn;
		}

		#region Class Property Declarations

		/// <summary>Returns a new IEntityRelation object, between SupplyOrderEntity and SupplyOrderItemEntity over the 1:n relation they have, using the relation between the fields:
		/// SupplyOrder.Id - SupplyOrderItem.SupplyOrderId
		/// </summary>
		public virtual IEntityRelation SupplyOrderItemEntityUsingSupplyOrderId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany, "SupplyOrderItems" , true);
				relation.AddEntityFieldPair(SupplyOrderFields.Id, SupplyOrderItemFields.SupplyOrderId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderEntity", true);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderItemEntity", false);
				return relation;
			}
		}


		/// <summary>Returns a new IEntityRelation object, between SupplyOrderEntity and CurrencyEntity over the m:1 relation they have, using the relation between the fields:
		/// SupplyOrder.CurrencyId - Currency.Id
		/// </summary>
		public virtual IEntityRelation CurrencyEntityUsingCurrencyId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Currency", false);
				relation.AddEntityFieldPair(CurrencyFields.Id, SupplyOrderFields.CurrencyId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("CurrencyEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between SupplyOrderEntity and ProjectEntity over the m:1 relation they have, using the relation between the fields:
		/// SupplyOrder.ProjectId - Project.Id
		/// </summary>
		public virtual IEntityRelation ProjectEntityUsingProjectId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Project", false);
				relation.AddEntityFieldPair(ProjectFields.Id, SupplyOrderFields.ProjectId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("ProjectEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between SupplyOrderEntity and SupplierEntity over the m:1 relation they have, using the relation between the fields:
		/// SupplyOrder.SupplierId - Supplier.Id
		/// </summary>
		public virtual IEntityRelation SupplierEntityUsingSupplierId
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "Supplier", false);
				relation.AddEntityFieldPair(SupplierFields.Id, SupplyOrderFields.SupplierId);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplierEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderEntity", true);
				return relation;
			}
		}
		/// <summary>Returns a new IEntityRelation object, between SupplyOrderEntity and UserEntity over the m:1 relation they have, using the relation between the fields:
		/// SupplyOrder.CreatedBy - User.Id
		/// </summary>
		public virtual IEntityRelation UserEntityUsingCreatedBy
		{
			get
			{
				IEntityRelation relation = new EntityRelation(SD.LLBLGen.Pro.ORMSupportClasses.RelationType.ManyToOne, "User", false);
				relation.AddEntityFieldPair(UserFields.Id, SupplyOrderFields.CreatedBy);
				relation.InheritanceInfoPkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("UserEntity", false);
				relation.InheritanceInfoFkSideEntity = InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo("SupplyOrderEntity", true);
				return relation;
			}
		}
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSubTypeRelation(string subTypeEntityName) { return null; }
		/// <summary>stub, not used in this entity, only for TargetPerEntity entities.</summary>
		public virtual IEntityRelation GetSuperTypeRelation() { return null;}
		#endregion

		#region Included Code

		#endregion
	}
	
	/// <summary>Static class which is used for providing relationship instances which are re-used internally for syncing</summary>
	internal static class StaticSupplyOrderRelations
	{
		internal static readonly IEntityRelation SupplyOrderItemEntityUsingSupplyOrderIdStatic = new SupplyOrderRelations().SupplyOrderItemEntityUsingSupplyOrderId;
		internal static readonly IEntityRelation CurrencyEntityUsingCurrencyIdStatic = new SupplyOrderRelations().CurrencyEntityUsingCurrencyId;
		internal static readonly IEntityRelation ProjectEntityUsingProjectIdStatic = new SupplyOrderRelations().ProjectEntityUsingProjectId;
		internal static readonly IEntityRelation SupplierEntityUsingSupplierIdStatic = new SupplyOrderRelations().SupplierEntityUsingSupplierId;
		internal static readonly IEntityRelation UserEntityUsingCreatedByStatic = new SupplyOrderRelations().UserEntityUsingCreatedBy;

		/// <summary>CTor</summary>
		static StaticSupplyOrderRelations()
		{
		}
	}
}
